<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var context = document.getElementById("context");
		if(context.value == ""){
			alert("评论不能为空！");
			return false;
		}
		return true;
	}
	
	function checkForm2(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != '0' && objs[i].checked){
				sign = sign + 1;
			}
		}
		if(sign <= 0){
			alert("请选择要删除的评论！");
			return false;
		}
		return true;
	}

	function back(){
		if("<c:out value='${isViewEmployeeBBS}'/>" == 1){
			window.location.href = "./employeeBBS.do";
		}else{
			window.location.href = "./index.do?action=mainPage";
		}
		window.location.target = "main";
	}
	
	function save(){
		if(checkForm()){
			document.viewEmployeeBBSForm.action = "./employeeBBS.do?action=addEmployeeBBSComment";
			document.viewEmployeeBBSForm.target = "main";
			document.viewEmployeeBBSForm.submit();
		}
	}
	
	function deleteEmployeeBBSComment(){
		if(checkForm2()){
			document.viewEmployeeBBSForm.action = "./employeeBBS.do?action=deleteEmployeeBBSComment";
			document.viewEmployeeBBSForm.target = "main";
			document.viewEmployeeBBSForm.submit();
		}
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("评论成功！");
		}else if("<c:out value='${result}'/>" == 2){
			alert("评论删除成功！");
		}
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="viewEmployeeBBSForm" action="" method="post">
	<table class="table_frame" cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<table class="table_title" cellpadding="0" cellspacing="0">
					<tr>
						<td class="title_lab" colspan="3">
							&nbsp;&nbsp;&nbsp;&nbsp;查看员工论坛
						</td>
					</tr>
					<tr><td height="15"></td></tr>
					<tr>
						<td valign="bottom" align="right">
							<a href="javascript:back();" title="返回" hidefocus="true">返回</a>&nbsp;&nbsp;&nbsp;&nbsp;
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="5"></td>
		</tr>
		<tr>
			<td valign="top">
				<table class="table_input" cellpadding="0" cellspacing="0" style="width: 800px;">
					<tr><td colspan="3"></td></tr>
					<tr>
						<td width="50"></td>
						<td align="center">${employeeBBS.subject}</td>
						<td width="50"></td>
					</tr>
					<tr><td colspan="3"></td></tr>
					<tr>
						<td width="50"></td>
						<td align="right" height="35">
							发布人：${employeeBBS.sendPerson}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							发布时间：<fmt:formatDate value="${employeeBBS.sendDate}" pattern="yyyy-MM-dd"/>&nbsp;&nbsp;
						</td>
						<td></td>
					</tr>
					<tr>
						<td width="50"></td>
						<td align="left"><pre>${employeeBBS.context}</pre></td>
						<td></td>
					</tr>
					<tr><td colspan="3"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<!-- 评论列表 -->
				<table class="table_input" cellpadding="0" cellspacing="0" style="width: 800px;">
					<tr>
						<td class="" width="50"></td>
						<td style="height: 30px;font-weight: bold;font-size: 14px;">员工评论(${fn:length(employeeBBS.comments)})</td>
						<td class="" width="100">
							<c:if test="${isManageEmployeeBBS == 1}">
							<a href="javascript:deleteEmployeeBBSComment();" target="main">删除评论</a>
							</c:if>
						</td>
						<td class="" width="50">
							<c:if test="${isManageEmployeeBBS == 1}">
							<input id="id" name="id" type="checkbox" value="0" onclick="checkAll('id')"/>
							</c:if>
						</td>
					</tr>
					<c:forEach var="comment" items="${employeeBBS.comments}">
					<tr>
						<td class="" width="50"></td>
						<td class="title_comment" align="left">&nbsp;&nbsp;
							评论人：${comment.commentPerson}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							评论日期：<fmt:formatDate value="${comment.commentDate}" pattern="yyyy-MM-dd"/>
						</td>
						<td class="title_comment">&nbsp;</td>
						<td class="" width="50">
							<c:if test="${isManageEmployeeBBS == 1}">
							<input id="id" name="id" type="checkbox" value="${comment.id}"/>
							</c:if>
						</td>
					</tr>
					<tr>
						<td width="50"></td>
						<td>
							<pre>${comment.context}</pre>
						</td>
						<td class="">&nbsp;</td>
						<td width="50"></td>
					</tr>
					</c:forEach>
				</table><br>
			</td>
		</tr>
		<tr>
			<td valign="top">
				<!-- 评论 -->
				<c:if test="${isSendEmployeeBBSComment == 1}">
				<table class="table_input" cellpadding="0" cellspacing="0" style="width: 800px;">
					<tr>
						<td width="30"></td>
						<td align="left" class="title">&nbsp;&nbsp;发表评论</td>
						<td width="50"></td>
					</tr>
					<tr>
						<td width="30"></td>
						<td>
							<textarea id="context" name="context" class="textarea_msg" style="height: 100px;width: 99%;" wrap="hard"></textarea>
							<input id="messageId" name="messageId" type="hidden" value="${employeeBBS.id}"/>
							<input id="commentPersonId" name="commentPersonId" type="hidden" value="${userId}"/>
						</td>
						<td></td>
					</tr>
					<tr>
						<td width="30"></td>
						<td class="title3" align="right">
							<input class="btn1" type="button" value=" 提 交 " onclick="save()"/>&nbsp;&nbsp;
						</td>
						<td></td>
					</tr>
				</table>
				</c:if>
			</td>
		</tr>
	</table>
</form>
</body>
</html>